//$Id:CashFlowDAO.java 2009-12-31 下午09:35:16
package com.walllee.module.pay;

import java.util.List;
import java.util.Map;

import com.walllee.core.dao.Page;
import com.walllee.core.dao.support.MysqlJdbcDAOImpl;

/**
 * 
 *
 * @author Wall.Lee(xiaoshan2242@gmail.com)
 */
public class CashFlowDAO extends MysqlJdbcDAOImpl{
	private final static String BASESELECTSQL = "select * from op_cash_flow" ;
	private final static String INSERTSQL = "INSERT INTO OP_CASH_FLOW(FLOWID,PAYDATE,PAYACCOUNT,PAYTYPE,OPERATOR,AMOUNT,SUMMARY) VALUES(?,?,?,?,?,?,?) ;" ;
	private final static String DELETESQL = "delete from op_cash_flow where flowId = ? " ;
	
	/**
	 * 获取所有的现金流水记录
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map> getAllCashFlow(){
		return this.getJdbcTemplate().queryForList(BASESELECTSQL);
	}
	
	/**
	 * 获取无条件查询的指定页面的数据
	 * @param page
	 * @param pageSize
	 * @return
	 */
	public Page queryPage(int page , int pageSize){
		return this.queryPage(BASESELECTSQL, null, page, pageSize) ;
	}
	
	/**
	 * 删除
	 * @param flowIds
	 */
	public void delete(String[] flowIds){
		for(String _id : flowIds ){
			this.getJdbcTemplate().update(DELETESQL, new Object[]{_id});
		}
	}
	/**
	 * 添加记录到数据库中
	 * @param entity
	 * @return
	 */
	public int addEntity(CashFlow entity){
		Object[] params = new Object[7];
		params[0] = entity.getFlowId();
		params[1] = entity.getPayDate();
		params[2] = entity.getPayAccount();
		params[3] = entity.getPayType();
		params[4] = entity.getOperator();
		params[5] = entity.getAmount();
		params[6] = entity.getSummary();
		return this.getJdbcTemplate().update(INSERTSQL, params) ;
	}
}
